<?php
/*************************************************

新闻采集API - the
Author: reload <17-7-21>

*************************************************/
// class Wanying{
//     public  function login(){
//         $url = "http://113.108.110.189:84/jinrongjie8/login";
//         $params = array(
//             'username':"8hjie",
//             'password':'1234',
//         );
//         $content = $this->juhecurl($url,$params,$ispost=1);
//         return $content;
//     }


//     public function juhecurl($url,$params=false,$ispost=0){
//         $httpInfo = array();
//         $ch = curl_init();
//         curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );
//         curl_setopt( $ch, CURLOPT_USERAGENT , 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22' );
//         curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 30 );
//         curl_setopt( $ch, CURLOPT_TIMEOUT , 30);
//         curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true );
//         if( $ispost )
//         {
//             curl_setopt( $ch , CURLOPT_POST , true );
//             curl_setopt( $ch , CURLOPT_POSTFIELDS , $params );
//             curl_setopt( $ch , CURLOPT_URL , $url );
//         }
//         else
//         {
//             if($params){
//                 curl_setopt( $ch , CURLOPT_URL , $url.'?'.$params );
//             }else{
//                 curl_setopt( $ch , CURLOPT_URL , $url);
//             }
//         }
//         $response = curl_exec( $ch );
//         if ($response === FALSE) {
//             //echo "cURL Error: " . curl_error($ch);
//             return false;
//         }
//         $httpCode = curl_getinfo( $ch , CURLINFO_HTTP_CODE );
//         $httpInfo = array_merge( $httpInfo , curl_getinfo( $ch ) );
//         curl_close( $ch );
//         return $response;
//     }


// }
// 
/*************************************************

新闻采集API - the
Author: reload <17-7-21>

*************************************************/
class Todayapi{
    public  function get_news(){
        $url = "http://v.juhe.cn/toutiao/index?type=caijing&key=2d5013af92c1298226953a40954aad7c";
        $content = $this->juhecurl($url);
        return $content;
    }


    public function juhecurl($url,$params=false,$ispost=0){
        $httpInfo = array();
        $ch = curl_init();
        curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );
        curl_setopt( $ch, CURLOPT_USERAGENT , 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22' );
        curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 30 );
        curl_setopt( $ch, CURLOPT_TIMEOUT , 30);
        curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true );
        if( $ispost )
        {
            curl_setopt( $ch , CURLOPT_POST , true );
            curl_setopt( $ch , CURLOPT_POSTFIELDS , $params );
            curl_setopt( $ch , CURLOPT_URL , $url );
        }
        else
        {
            if($params){
                curl_setopt( $ch , CURLOPT_URL , $url.'?'.$params );
            }else{
                curl_setopt( $ch , CURLOPT_URL , $url);
            }
        }
        $response = curl_exec( $ch );
        if ($response === FALSE) {
            //echo "cURL Error: " . curl_error($ch);
            return false;
        }
        $httpCode = curl_getinfo( $ch , CURLINFO_HTTP_CODE );
        $httpInfo = array_merge( $httpInfo , curl_getinfo( $ch ) );
        curl_close( $ch );
        return $response;
    }


}